import joblib
import pandas as pd
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from xgboost import XGBRegressor, XGBClassifier

data= pd.read_csv('../../data/raw/test2.csv')
#找出所有数据类型为object的列
categorical_cols = data.select_dtypes(include=['object']).columns #.tolist()
# 初始化LabelEncoder
le = LabelEncoder()
#建立循环
for i in categorical_cols:
    #对每个object类型列的数据进行处理，并返回给原列
    data[i]=le.fit_transform(data[i])

# x=data[['OverTime','StockOptionLevel','JobLevel','JobRole','MaritalStatus','TotalWorkingYears','Age','JobInvolvement','YearsWithCurrManager','YearsInCurrentRole','JobSatisfaction','YearsAtCompany','EnvironmentSatisfaction','NumCompaniesWorked','WorkLifeBalance','MonthlyIncome']]

y=data['Attrition']
es=joblib.load('./model04_cut.pkl')
y_pre = es.predict_proba(x)[:,1]
auc = roc_auc_score(y, y_pre)
print(f"AUC Score: {auc:.4f}")